#!/bin/bash
trap 'echo Abort ; exit 1' ERR

if(test -L $0) then
    	auxlink=`ls -l $0 | sed 's/^[^>]*-> //g'`
    	M_HOME=`dirname $auxlink`/
else 
    	M_HOME=`dirname $0`/
fi
cd $M_HOME

echo Build U-Boot.
rm u-boot-2008.10 -rf
tar xf u-boot-2008.10.tar.bz2
pushd u-boot-2008.10
patch --silent -p1 < ../patch
popd
pushd u-boot-2008.10
make at91sam9263ek_config > /dev/null
make > /dev/null
cp u-boot.bin /opt/9263/deploy/
cp tools/mkimage /opt/9263/deploy/
popd
rm u-boot-2008.10 -rf
